package com.sky.mapper;

import com.sky.entity.AddressBook;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AddressBookMapper {
    void addAddressBook(AddressBook addressBook);

    List<AddressBook> list(Long userId);

    @Select("select * from address_book where user_id = #{userId} and is_default = 1")
    AddressBook defaultAddressBook(Long userId);

    @Select("select * from address_book where id = #{id} and user_id = #{userId}")
    AddressBook getAddressBookById(Long userId,Integer id);

    void update(AddressBook addressBook);

    @Delete("delete from address_book where id = #{id} and user_id = #{userId}")
    void deleteAddressBook(Long userId, Integer id);
}
